package com.shop.user.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shop.entity.pojo.Brands;
import com.shop.user.mapper.BrandsMapper;
import com.shop.user.service.BrandsService;
import com.shop.utils.common.enums.Message;
import com.shop.utils.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class BrandsServiceImpl extends ServiceImpl<BrandsMapper, Brands> implements BrandsService {

    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public Result<List<Brands>> getBrandsList() {
        String key= Message.WeChat_Key_Brands_All;
        List<Brands> check = (List<Brands>) redisTemplate.opsForValue().get(key);
        if (check!=null&&check.size()>0) {
            return Result.okResult(check);
        }
        List<Brands> list = list();
        redisTemplate.opsForValue().set(key,list);
        return Result.okResult(list);
    }
}
